/***********************************************************************
 * Module:  QuestionShortcut.java
 * Author:  DAC
 * Purpose: Defines the Class QuestionShortcut
 ***********************************************************************/
package com.group1.model;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

/** @pdOid 078243f7-7188-438d-9bdb-835c49b528fd */
public class QuestionShortcut {
   /** @pdOid a9bee316-32ba-43dd-b537-72bb9ad44e14 */
   protected void finalize() {
      // TODO: implement
   }
   
   /** @pdOid b9d215fa-a699-4948-bb1e-979093a8a421 */
   public Integer questshortId;
   /** @pdOid b38e139a-4d4a-44cd-8b8d-47c7aab77e36 */
   public java.lang.String questionshortNote;
   
   /** @pdRoleInfo migr=no name=Question assc=shortcutsToQuestions mult=0..1 side=A */
   public Question question;
   /** @pdRoleInfo migr=no name=Topic assc=shortcutsInsideOfTopics mult=0..1 side=A */
   public Topic topic;
   
   /** @param questScID 
    * @param questID 
    * @param topicID 
    * @param questScNote
    * @pdOid 886c0439-91f6-45eb-a235-b9be30446397 */
   public QuestionShortcut(Integer questScID, Integer questID, Integer topicID, String questScNote)  {
      // TODO: implement
   }
   
   /** @param session
    * @pdOid 7a21b5f7-a086-4e2b-8705-52b9b3af349e */
   public static List<QuestionShortcut> getAllQuestSc(Session session) {
      // TODO: implement
	   Query query = session.createQuery("from QuestionShortcut");
	   List<QuestionShortcut> list = query.list();
      return list;
   }
   
   /** @param questScID 
    * @param session
    * @pdOid 2ac0a296-4b81-4d57-a391-b9fcbcc2c27d */
   public static QuestionShortcut getQuestScByID(Integer questScID, Session session) {
      // TODO: implement
      return (QuestionShortcut) session.get(QuestionShortcut.class, questScID);
   }
   
   /** @param topicID 
    * @param session
    * @pdOid 8c4a9369-d22e-4188-aad5-8d1765c9103f */
   public static List<QuestionShortcut> getQuestScByTopic(Integer topicID, Session session) {
      // TODO: implement
	   Query query = session.createQuery("from QuestionShortcut where TOPIC_ID = " + topicID);
	   List<QuestionShortcut> list = query.list();
      return list;
   }
   
   /** @param questID 
    * @param session
    * @pdOid 1ae0b4c4-80e9-4ad0-a242-ff32fe869634 */
   public static List<QuestionShortcut> getQuestScByQuest(Integer questID, Session session) {
      // TODO: implement
	   Query query = session.createQuery("from QuestionShortcut where QUESTION_ID = " + questID);
	   List<QuestionShortcut> list = query.list();
      return list;
   }
   
   /** @pdOid 3e6cf00f-299b-427d-9f35-bc855a8e0d50 */
   public Integer getQuestshortId() {
      return questshortId;
   }
   
   /** @param newQuestshortId
    * @pdOid bafd2bd5-fbd0-4ea2-9445-1a9beeb560cb */
   public void setQuestshortId(Integer newQuestshortId) {
      questshortId = newQuestshortId;
   }
   
   /** @pdOid 1b16c86a-946c-492a-b85d-698c607108a2 */
   public java.lang.String getQuestionshortNote() {
      return questionshortNote;
   }
   
   /** @param newQuestionshortNote
    * @pdOid c3b39ce8-8ebe-41af-9854-97c2316dc211 */
   public void setQuestionshortNote(java.lang.String newQuestionshortNote) {
      questionshortNote = newQuestionshortNote;
   }
   
   /** @pdOid f9d5bc2f-a0d0-4405-a5dc-a3f9043c7e3b */
   public QuestionShortcut() {
      // TODO: implement
   }
   
   
   /** @pdGenerated default parent getter */
   public Question getQuestion() {
      return question;
   }
   
   /** @pdGenerated default parent setter
     * @param newQuestion */
   public void setQuestion(Question newQuestion) {
      if (this.question == null || !this.question.equals(newQuestion))
      {
         if (this.question != null)
         {
            Question oldQuestion = this.question;
            this.question = null;
            oldQuestion.removeQuestionShortcut(this);
         }
         if (newQuestion != null)
         {
            this.question = newQuestion;
            this.question.addQuestionShortcut(this);
         }
      }
   }
   /** @pdGenerated default parent getter */
   public Topic getTopic() {
      return topic;
   }
   
   /** @pdGenerated default parent setter
     * @param newTopic */
   public void setTopic(Topic newTopic) {
      if (this.topic == null || !this.topic.equals(newTopic))
      {
         if (this.topic != null)
         {
            Topic oldTopic = this.topic;
            this.topic = null;
            oldTopic.removeQuestionShortcut(this);
         }
         if (newTopic != null)
         {
            this.topic = newTopic;
            this.topic.addQuestionShortcut(this);
         }
      }
   }

}